home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / role / Ang261Lib.lha / src / sets.c < prev    next >
C/C++ Source or Header  |  1994-10-22  |  8KB  |  416 lines

  1. /*
  2.  * sets.c: code to emulate the original Pascal sets 
  3.  *
  4.  * Copyright (c) 1989 James E. Wilson 
  5.  *
  6.  * This software may be copied and distributed for educational, research, and
  7.  * not for profit purposes provided that this copyright and statement are
  8.  * included in all such copies. 
  9.  */
  10.  
  11. #include "constant.h"
  12. #include "config.h"
  13. #include "types.h"
  14. #include "externs.h"
  15.  
  16. int 
  17. set_room(element)
  18. register int element;
  19. {
  20.     if ((element == DARK_FLOOR) || (element == LIGHT_FLOOR) ||
  21.     (element == NT_DARK_FLOOR) || (element == NT_LIGHT_FLOOR))
  22.     return (TRUE);
  23.     return (FALSE);
  24. }
  25.  
  26. int 
  27. set_corr(element)
  28. register int element;
  29. {
  30.     if (element == CORR_FLOOR || element == BLOCKED_FLOOR)
  31.     return (TRUE);
  32.     return (FALSE);
  33. }
  34.  
  35. int 
  36. set_floor(element)
  37. int element;
  38. {
  39.     if (element <= MAX_CAVE_FLOOR)
  40.     return (TRUE);
  41.     else
  42.     return (FALSE);
  43. }
  44.  
  45. int 
  46. set_corrodes(e)               /* changed -CFT */
  47. inven_type *e;
  48. {
  49.     int element = e->tval;
  50.  
  51.     switch (element) {
  52.       case TV_SWORD:
  53.       case TV_HELM:
  54.       case TV_SHIELD:
  55.       case TV_HARD_ARMOR:
  56.     if ((e->flags2 & TR_ARTIFACT)    /* shouldn't kill artifacts -CFT */
  57.         ||(e->flags & TR_RES_ACID)    /* can't check outside, because flags */
  58.         ||(e->flags2 & TR_IM_ACID))    /* used differently in potions/etc */
  59.         return (FALSE);
  60.     return (TRUE);
  61.       case TV_WAND:
  62.     return (TRUE);
  63.     }
  64.     return (FALSE);
  65. }
  66.  
  67.  
  68. int 
  69. set_flammable(e)           /* changed -CFT */
  70. inven_type *e;
  71. {
  72.     int element = e->tval;
  73.  
  74.     switch (element) {
  75.       case TV_ARROW:
  76.       case TV_BOW:
  77.       case TV_HAFTED:
  78.       case TV_POLEARM:
  79.       case TV_BOOTS:
  80.       case TV_GLOVES:
  81.       case TV_CLOAK:
  82.       case TV_SOFT_ARMOR:
  83.     if ((e->flags2 & TR_ARTIFACT)    /* shouldn't kill artifacts -CFT */
  84.         ||(e->flags & TR_RES_FIRE)    /* can't check outside, because flags */
  85.         ||(e->flags2 & TR_IM_FIRE))    /* used differently in potions/etc */
  86.         return (FALSE);
  87.     return (TRUE);
  88.       case TV_STAFF:
  89.       case TV_SCROLL1:
  90.       case TV_SCROLL2:
  91.       case TV_FLASK:
  92.     return (TRUE);
  93.       case TV_LIGHT:
  94.     if (e->subval >= 192)       /* only torches... -CFT */
  95.         return (TRUE);
  96.     else
  97.         return (FALSE);
  98.     }
  99.     return (FALSE);
  100. }
  101.  
  102.  
  103. int 
  104. set_frost_destroy(e)           /* changed -CFT */
  105. inven_type *e;
  106. {
  107.     int element = e->tval;
  108.  
  109.     if ((element == TV_POTION1) || (element == TV_POTION2)
  110.     || (element == TV_FLASK))
  111.     return (TRUE);
  112.     return (FALSE);
  113. }
  114.  
  115.  
  116. int 
  117. set_meteor_destroy(e)           /* added -DGK */
  118. inven_type *e;
  119. {
  120.     int8u fi, fo;
  121.  
  122.     fi = set_fire_destroy(e);
  123.     fo = set_frost_destroy(e);
  124.     return (fi | fo);
  125. }
  126.  
  127.  
  128. int 
  129. set_mana_destroy(e)           /* added -DGK */
  130. inven_type *e;
  131. {                   /* destroy everything but artifacts */
  132.     int element = e->tval;
  133.  
  134.     if ((element >= TV_MIN_ENCHANT) && (element <= TV_MAX_WEAR) &&
  135.     (e->flags2 & TR_ARTIFACT))
  136.     return (FALSE);
  137.     return (TRUE);
  138. }
  139.  
  140.  
  141. int 
  142. set_holy_destroy(e)           /* added -DGK */
  143. inven_type *e;
  144. {
  145.     int element = e->tval;
  146.  
  147.     if ((element >= TV_MIN_ENCHANT) && (element <= TV_MAX_WEAR) &&
  148.     (e->flags & TR_CURSED) && (!(e->flags2 & TR_ARTIFACT)))
  149.     return (TRUE);
  150.     return (FALSE);
  151. }
  152.  
  153.  
  154. int 
  155. set_plasma_destroy(e)           /* added -DGK */
  156. inven_type *e;
  157. {
  158.     int8u fi, li;
  159.  
  160.     fi = set_fire_destroy(e);
  161.     li = set_lightning_destroy(e);
  162.     return (fi | li);
  163. }
  164.  
  165.  
  166. int 
  167. set_acid_affect(e)           /* changed -CFT */
  168. inven_type *e;
  169. {
  170.     int element = e->tval;
  171.  
  172.     switch (element) {
  173.       case TV_BOLT:
  174.       case TV_ARROW:
  175.       case TV_BOW:
  176.       case TV_HAFTED:
  177.       case TV_POLEARM:
  178.       case TV_BOOTS:
  179.       case TV_GLOVES:
  180.       case TV_CLOAK:
  181.       case TV_SOFT_ARMOR:
  182.     if ((e->flags2 & TR_ARTIFACT)    /* shouldn't kill artifacts -CFT */
  183.         ||(e->flags & TR_RES_ACID)    /* can't check outside, because flags */
  184.         ||(e->flags2 & TR_IM_ACID))    /* used differently in potions/etc */
  185.         return (FALSE);
  186.     return (TRUE);
  187.       case TV_MISC:
  188.       case TV_CHEST:
  189.     return (TRUE);
  190.     }
  191.     return (FALSE);
  192. }
  193.  
  194.  
  195. int 
  196. set_lightning_destroy(e)       /* changed -CFT */
  197. inven_type *e;
  198. {
  199.     int element = e->tval;
  200.  
  201.     switch (element) {
  202.       case TV_RING:
  203.     if ((e->flags2 & TR_ARTIFACT)    /* shouldn't kill artifacts -CFT */
  204.         ||(e->flags & TR_RES_LIGHT)    /* can't check outside, because flags */
  205.         ||(e->flags2 & TR_IM_LIGHT))    /* used differently in potions/etc */
  206.         return (FALSE);
  207.     return (TRUE);
  208.       case TV_WAND:
  209.     return (TRUE);
  210.     }
  211.     return (FALSE);
  212. }
  213.  
  214.  
  215. int 
  216. set_null(e)
  217. inven_type *e;
  218. {
  219.     return (FALSE);
  220. }
  221.  
  222.  
  223. int 
  224. set_acid_destroy(e)           /* changed -CFT */
  225. inven_type *e;
  226. {
  227.     int element = e->tval;
  228.  
  229.     switch (element) {
  230.       case TV_ARROW:
  231.       case TV_BOW:
  232.       case TV_HAFTED:
  233.       case TV_POLEARM:
  234.       case TV_BOOTS:
  235.       case TV_GLOVES:
  236.       case TV_CLOAK:
  237.       case TV_HELM:
  238.       case TV_SHIELD:
  239.       case TV_HARD_ARMOR:
  240.       case TV_SOFT_ARMOR:
  241.     if ((e->flags2 & TR_ARTIFACT)    /* shouldn't kill artifacts -CFT */
  242.         ||(e->flags & TR_RES_ACID)    /* can't check outside, because flags */
  243.         ||(e->flags2 & TR_IM_ACID))    /* used differently in potions/etc */
  244.         return (FALSE);
  245.     return (TRUE);
  246.       case TV_SCROLL1:
  247.       case TV_SCROLL2:
  248.       case TV_FOOD:
  249.       case TV_OPEN_DOOR:
  250.       case TV_CLOSED_DOOR:
  251.       case TV_STAFF:
  252.     return (TRUE);
  253.     }
  254.     return (FALSE);
  255. }
  256.  
  257.  
  258. int 
  259. set_fire_destroy(e)           /* changed -CFT */
  260. inven_type *e;
  261. {
  262.     int element = e->tval;
  263.  
  264.     switch (element) {
  265.       case TV_ARROW:
  266.       case TV_BOW:
  267.       case TV_HAFTED:
  268.       case TV_POLEARM:
  269.       case TV_BOOTS:
  270.       case TV_GLOVES:
  271.       case TV_CLOAK:
  272.       case TV_SOFT_ARMOR:
  273.     if ((e->flags2 & TR_ARTIFACT)    /* shouldn't kill artifacts -CFT */
  274.         ||(e->flags & TR_RES_FIRE)    /* can't check outside, because flags */
  275.         ||(e->flags2 & TR_IM_FIRE))    /* used differently in potions/etc */
  276.         return (FALSE);
  277.     return (TRUE);
  278.       case TV_STAFF:
  279.       case TV_SCROLL1:
  280.       case TV_SCROLL2:
  281.       case TV_POTION1:
  282.       case TV_POTION2:
  283.       case TV_FLASK:
  284.       case TV_FOOD:
  285.       case TV_OPEN_DOOR:
  286.       case TV_CLOSED_DOOR:
  287.     return (TRUE);
  288.       case TV_LIGHT:
  289.     if (e->subval >= 192)       /* only torches... -CFT */
  290.         return (TRUE);
  291.     else
  292.         return (FALSE);
  293.     }
  294.     return (FALSE);
  295. }
  296.  
  297.  
  298. int 
  299. general_store(element)
  300. int element;
  301. {
  302.     switch (element) {
  303.       case TV_DIGGING:
  304.       case TV_BOOTS:
  305.       case TV_CLOAK:
  306.       case TV_FOOD:
  307.       case TV_FLASK:
  308.       case TV_LIGHT:
  309.       case TV_SPIKE:
  310.     return (TRUE);
  311.     }
  312.     return (FALSE);
  313. }
  314.  
  315.  
  316. int 
  317. armory(element)
  318. int element;
  319. {
  320.     switch (element) {
  321.       case TV_BOOTS:
  322.       case TV_GLOVES:
  323.       case TV_HELM:
  324.       case TV_SHIELD:
  325.       case TV_HARD_ARMOR:
  326.       case TV_SOFT_ARMOR:
  327.     return (TRUE);
  328.     }
  329.     return (FALSE);
  330. }
  331.  
  332.  
  333. int 
  334. weaponsmith(element)
  335. int element;
  336. {
  337.     switch (element) {
  338.       case TV_SLING_AMMO:
  339.       case TV_BOLT:
  340.       case TV_ARROW:
  341.       case TV_BOW:
  342.       case TV_HAFTED:
  343.       case TV_POLEARM:
  344.       case TV_SWORD:
  345.     return (TRUE);
  346.     }
  347.     return (FALSE);
  348. }
  349.  
  350.  
  351. int 
  352. temple(element)
  353. int element;
  354. {
  355.     switch (element) {
  356.       case TV_HAFTED:
  357.       case TV_SCROLL1:
  358.       case TV_SCROLL2:
  359.       case TV_POTION1:
  360.       case TV_POTION2:
  361.       case TV_PRAYER_BOOK:
  362.     return (TRUE);
  363.     }
  364.     return (FALSE);
  365. }
  366.  
  367.  
  368. int 
  369. alchemist(element)
  370. int element;
  371. {
  372.     switch (element) {
  373.       case TV_SCROLL1:
  374.       case TV_SCROLL2:
  375.       case TV_POTION1:
  376.       case TV_POTION2:
  377.     return (TRUE);
  378.     }
  379.     return (FALSE);
  380. }
  381.  
  382.  
  383. int 
  384. magic_shop(element)
  385. int element;
  386. {
  387.     switch (element) {
  388.       case TV_AMULET:
  389.       case TV_RING:
  390.       case TV_STAFF:
  391.       case TV_WAND:
  392.       case TV_SCROLL1:
  393.       case TV_SCROLL2:
  394.       case TV_POTION1:
  395.       case TV_POTION2:
  396.       case TV_MAGIC_BOOK:
  397.       case TV_ROD:
  398.     return (TRUE);
  399.     }
  400.     return (FALSE);
  401. }
  402.  
  403. int 
  404. blackmarket(element)
  405. int element;
  406. {
  407.     return (TRUE);
  408. }
  409.  
  410. int 
  411. home(element)
  412. int element;
  413. {
  414.     return (TRUE);
  415. }
  416.